package cn.java8practise.lambda;

/**
 * lambda表达式入门demo1
 *
 * Created by 杨志远 on 2017/4/18
 * email faryangsh@163.com
 */
public class RunableTest {

    public static void main(String[] args) {
        //传统的做法
        Runnable runnable1=new Runnable() {
            @Override
            public void run() {
                System.out.println("run3");
            }
        };
        process(runnable1);

        //使用lambda构造runnable，再进行方法传递
        Runnable runnable2 = () ->System.out.println("run1");
        process(runnable2);

        //直接传递lambda表达式，将run方法的动作作为参数进行传递
        process(() -> System.out.println("run2"));
    }

    private static void process(Runnable runnable) {
        runnable.run();
    }


}
